/**
 * File ManufacturerMAS.java created by Pablo Díaz Fernández
 * on 06/04/2012 for the project supply-chain-simulator
 */
package org.lsk.pfc.scsim.model.mas;

import jade.wrapper.ContainerController;
import jade.wrapper.StaleProxyException;

import org.lsk.pfc.scsim.model.agent.ControlAgent;
import org.lsk.pfc.scsim.model.behaviour.forecast.OneToOneModelFCB;
import org.lsk.pfc.scsim.model.exception.MASCreationException;
import org.lsk.pfc.scsim.model.util.ConstantKeys;

/**
 * Multi-agent system for the slaves of the chain that play the role of the
 * manufacturer.
 * 
 * @author Pablo Díaz Fernández
 * 
 */
public final class ManufacturerMAS extends MultiAgentSystem {

	/**
	 * Constructor that initializes object attributes.
	 * 
	 * @param masName
	 *            The MAS name to set.
	 * @param cc
	 *            {@link ContainerController} The Jade Container Controller
	 *            needed to create agents.
	 * 
	 * @throws MASCreationException
	 *             Exception creating agents
	 */
	public ManufacturerMAS(final String masName, final ContainerController cc)
	        throws MASCreationException {
		super(masName, cc);
		try {
			super.setControlAgent(cc.createNewAgent(masName
			        + ConstantKeys.CA_SUFFIX,
			        ControlAgent.class.getCanonicalName(), new Object[] {
			                masName, ControlAgent.MANUFACTURER }));
			super.addForecastingAgent(cc.createNewAgent(
			        masName + ConstantKeys.FA_SUFFIX,
			        ControlAgent.class.getCanonicalName(),
			        new Object[] { masName,
			                OneToOneModelFCB.class.getCanonicalName() }));
		} catch (StaleProxyException e) {
			throw new MASCreationException(masName, e);
		}
	}

}